<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <input id="inp" type="text">
    <button id="search">查询</button>
    <button id="withdraw">撤回</button>

    <script src="../jquery/jquery.js"></script>
    <script>

        function bigDie() {
            const record = [];

            return {
                onRecord() {
                    // 输入值就记录
                    if ($('#inp').val().trim()) {
                        record.push($('#inp').val());
                        console.log(record);
                    }
                },
                onWithDraw() {
                    record.pop();
                    $('#inp').val(record.slice(-1)[0]);
                },
            };
        }

        const event = bigDie();
        $('#search').on('click', event.onRecord);
        $('#withdraw').on('click', event.onWithDraw);
    </script>
</body>
</html>
